
#define BOOST_TEST_MAIN
//#define BOOST_TEST_MODULE tcp_data_handler

#include <boost/test/included/unit_test.hpp>

#include "lua_plugin_manager.h"



BOOST_AUTO_TEST_SUITE(lua_loader) ;


BOOST_AUTO_TEST_CASE(load)
{
    LuaPluginManager lua_manager ;
    BOOST_REQUIRE(lua_manager.init()==0) ;

    BOOST_REQUIRE(lua_manager.load("plugin_login.lua")==0) ;
    BOOST_REQUIRE(lua_manager.load("plugin_logout.lua")==0) ;
    lua_manager.run(1,NULL) ;
    lua_manager.run(2,NULL) ;

    /*
    for(int i = 0 ; i < 10;++i)
    {
        BOOST_REQUIRE(lua_manager.load("plugin_login.lua")==0) ;
        lua_manager.run("on_login",NULL) ;
        sleep(1);
        lua_manager.run("on_login",NULL) ;
        sleep(1) ;
        lua_manager.run("on_login",NULL) ;
        sleep(10) ;
        
    }
    */
    
    //BOOST_CHECK(conn.get_status() == tcp_data_handler::STATUS_CONNECTED) ;


}

BOOST_AUTO_TEST_CASE(load_perf)
{
    std::vector<LuaPluginManager> lua_container(10000) ;
    int begin = time(0) ;
    for(int i = 0 ; i < 10000 ; ++i)
    {
        LuaPluginManager& lua_manager = lua_container[i] ;
        BOOST_REQUIRE(lua_manager.init()==0) ;
        BOOST_REQUIRE(lua_manager.load("plugin_login.lua")==0) ;
    }
    printf("elipsed time:%ld s\n",time(0) - begin) ;
        
}



BOOST_AUTO_TEST_SUITE_END() ;

